
$("#btn-success").on('click',  function(event) {
// location.reload()   //刷新当前页面
// 词云图JS
var worldCloudcharts=echarts.init(document.getElementById('MinGan_ciyun'));
var worldCloudoption = {
 			    tooltip: {
 			        show: true
 			    },
 			    series: [{
 			        name: '敏感词语',
 			        type: 'wordCloud',
 			        sizeRange: [6, 28],
 			        rotationRange: [-45, 90],
              drawOutOfBound:true,
 			        textPadding: 0,
 			        autoSize: {
 			            enable: true,
 			            minSize: 6
 			        },
 			        textStyle: {
 			            normal: {
 			                color: function() {
 			                    return 'rgb(' + [
 			                        Math.round(Math.random() * 160),
 			                        Math.round(Math.random() * 160),
 			                        Math.round(Math.random() * 160)
 			                    ].join(',') + ')';
 			                }
 			            },
 			            emphasis: {
 			                shadowBlur: 10,
 			                shadowColor: '#333'
 			            }
 			        },
 			        data: []
 			    }]
 			};
      
      
//进度条绘制
      window.onload=function(){
          (function(obj){
              obj.win={
                  /**
                   * 环形进度条
                   * @param el：DOM对象
                   * @param val:数值
                   * @param bg:背景颜色
                   * @param color:环颜色
                   * @param textColor：数字颜色
                   * @param fontSize：数字字体大小
                   * @param size:环宽度
                   * @param r:环内半径
                   * @param time:动画时间
                   * @param easing:动画类型:
                   *  'linear'
                   *  '<' or 'easeIn' or 'ease-in'
                   *  '>' or 'easeOut' or 'ease-out'
                   *  '<>' or 'easeInOut' or 'ease-in-out'
                   *  'backIn'or 'back-in'
                   *  'backOut' or 'back-out'
                   *  'elastic'
                   *  'bounce'
                   */
                  loopFun:function(el,val,bg,color,textColor,fontSize,size,r,time,easing){
                      var si =r+size/2;
                      var xy=r+size;
                      if(val<0||val>100){
                          return alert('请输入0~100之间的数')
                      }
                      var paper = Raphael(el,(r+size)*2,(r+size)*2);
                      paper.circle(xy,xy,r).attr({
                          'stroke-width': size,
                          stroke:bg
                      });
                      paper.customAttributes.arc=function(val){
                          var v = 360*val/100,
                              s = -180,
                              e = s+v,
                              x = xy,
                              y = xy,
                              rad = Math.PI/180,
                              x1 = x+r*Math.sin(-s*rad),
                              y1 = y+r*Math.cos(-s*rad),
                              x2 = x+r*Math.sin(-e*rad),
                              y2 = y+r*Math.cos(-e*rad),
                              path=[
                                  ['M',x1,y1],
                                  ['A',r,r,0,+(e-s>180),1,x2,y2]
                              ];
                          return {
                              path:path
                          };
                      };
                      var an = paper.path().attr({
                          'stroke-width': size,
                          stroke:color,
                          arc: 0.01
                      });
                      an.animate({
                          stroke:color,
                          arc:val
                      },time,easing);
                      setTimeout(function(){
                          if(val==100){
                              paper.circle(xy,xy,r).attr({
                                  'stroke-width': size,
                                  stroke:color
                              });
                          }
                      },time);
                      paper.customAttributes.txt=function(val){
                          return {
                              text:Math.floor(val*100)/100+'%'
                          }
                      };
                      var l = paper.text(xy,xy).attr({
                          txt:0,
                          'fill':textColor,
                          'font-size':fontSize,
                          'font-weight':700
                      });
                      l.animate({
                          txt:val
                      },time);
                  },

              };
          })(window);
      
      }
      
      // var phone_CiYun = window.localStorage.getItem("clickPhone");
      // var data = {phone_num:phone_CiYun}
      
      //var request_parameters = {type: "get_sentive_user"}   //默认传值
        var request_parameters = {type: "get_this_phone_num_info",phone_num:$("#inputPassword").val()}    //动态传值
      //ajax程序      写在了最后
            $.ajax({
              url:"http://127.0.0.1:9998/analysis/get_this_phone_num_info",
              type:"POST",
              time:'3000',  
              dataType: "json",
              data: request_parameters,
              success:function(response){

                  rsp = response.data;
  // 词云图JS 通过它的post >>写>> 【进度条】JS 
                var data_value = parseFloat(rsp.info.inclination) //转小数型
                data_value_fin = data_value.toFixed(2);
                console.log(data_value_fin);
                var Zheng = 0;
                var Fu = 0;
                if (data_value_fin>0) {
                  Zheng = data_value_fin;
                  Fu = 0;
                }
                if (data_value_fin<0) {
                  Zheng = 0;
                  Fu = data_value_fin;
                }
                if (data_value_fin==0) {
                  Zheng = 0;
                  Fu = 0;
                }
                
                console.log(Zheng);
                console.log(Fu);
                var get_Zheng_fin = 100*Zheng;            //为了图片显示做的 数据处理
                var get_Fu_fin = 100*(Math.abs(Fu));      //为了图片显示做的 数据处理
                console.log(get_Zheng_fin);
                console.log(get_Fu_fin);
              $('.div1').html("");
              $('.div2').html("");

                // 分级
                  if (get_Zheng_fin>=0){
                      document.getElementById('YuJingFenJiBG').style.background="#00A0E9";
                       document.getElementById('MinGan_JinDuTiao_FenJitxt').innerHTML="良好"

                  }
                  if (get_Fu_fin>0 && get_Fu_fin<=10){
                       document.getElementById('YuJingFenJiBG').style.background="#FFD700";
                       document.getElementById('MinGan_JinDuTiao_FenJitxt').innerHTML="低风险"
                  }
                  if (get_Fu_fin>10 && get_Fu_fin<=30){
                       document.getElementById('YuJingFenJiBG').style.background="#FF8247";
                       document.getElementById('MinGan_JinDuTiao_FenJitxt').innerHTML="高风险"
                  }
                  if (get_Fu_fin>30 && get_Fu_fin<=100){
                       document.getElementById('YuJingFenJiBG').style.background="#B22222";
                       document.getElementById('MinGan_JinDuTiao_FenJitxt').innerHTML="危急"
                  }







              win.loopFun($('.div1')[0],get_Fu_fin,'#ccc','#333','#333','20px',20,60,1000,'bounce');
              win.loopFun($('.div2')[0],get_Zheng_fin,'#ccc','#00A0E9','#00A0E9','20px',20,60,1000,'back-out');
              
                
  // 词云图JS 通过它的post >>写>> 【常用联系人】JS              
                var str = ""
                var j = 1
                data_usucontacts = rsp.frequentContacts      //都拿来
                for(var one in data_usucontacts){                         //遍历一下
                  str = str + "<tr><td>" + j  + ":&nbsp;&nbsp;</td>"+ "<td>" 
                      + data_usucontacts[one].phoneNum2 +"</td>"+ "<td> &nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;" + data_usucontacts[one].relation +"</td></tr>" //选择要哪个
                      j = j + 1;
                }
                // document.getElementById('table_pai').innerHTML = ""
                  document.getElementById('MinGan_UsualContact').innerHTML = ""   //清空 #table_pai div
                var table = $('#MinGan_UsualContact').append(str)
                
  // 词云图JS实现
                 //var data_name = []
                 var JsonList = []    
                 if(response.code == 1){
                   data_name = rsp.info.sensitiveWord.split(",")    //都拿来
                   for(var one in data_name){                   //一个一个遍历
                      var word_name = {}
                      var value = Math.random()*1
                      word_name['name'] = data_name[one]
                      word_name['value'] = value
                     JsonList.push(word_name)
                    }
                    console.log(JsonList)
                   worldCloudoption.series[0].data = JsonList ;
                   worldCloudcharts.setOption(worldCloudoption);
                }
              },
              error:function(e) {
                /* Act on the event */
                console.log(e);
              }
              
              
      });
            
            
});

